﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StrategyGame.Utilities;

namespace StrategyGame
{
    public class SpecialAbility
    {
        public List<SimplePoint> Targets;
        public GameEffect Effect;
        public int Power;
        public CharacterClass AbilityOwner;
        public bool ReplacesAttack;
        public bool RequiresAddtionalTarget;

        public SpecialAbility(List<SimplePoint> targets, GameEffect newEffect)
        {
            Effect = newEffect;
            Targets = targets;
            
        }

        public virtual bool Execute(CharacterClass rushTarget, Arena arena, List<CharacterClass> additonalTargets)
        {
            //Should the player still deal normal damage
            return true;
        }

        public virtual SpecialAbility GetInstance(int power)
        {
            return new SpecialAbility(Targets.ToList(), Effect.GetInstance(power)) 
            {Power = power, ReplacesAttack = this.ReplacesAttack };
         
        }

        public virtual Selectables GetAddtionalTargetables(Arena arena)
        {
            return null;
        }

        public virtual List<CharacterClass> GetTargets(CharacterClass attacker, Arena arena)
        {
            return arena.GetTargetedSpaces(attacker.Square,Targets)
                    .Where(f=>f.Character != null)
                    .Select(f=>f.Character).ToList();
        }
    }
}
